if(CONFIG_HAS_NORDIC_DRIVERS OR CONFIG_HAS_NRFX)
  zephyr_library()
endif()

if(CONFIG_HAS_NORDIC_DRIVERS)
  add_subdirectory(drivers)
endif()

if(CONFIG_HAS_NRFX)
  zephyr_include_directories(nrfx)
  zephyr_include_directories(nrfx/drivers/include)
  zephyr_include_directories(nrfx/mdk)
  zephyr_include_directories(.)

  # Define MDK defines globally
  zephyr_compile_definitions_ifdef(CONFIG_SOC_SERIES_NRF51X  NRF51)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52810       NRF52810_XXAA)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52811       NRF52811_XXAA)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52832       NRF52832_XXAA)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52833       NRF52833_XXAA)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF52840       NRF52840_XXAA)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF5340_CPUAPP NRF5340_XXAA_APPLICATION)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF5340_CPUNET NRF5340_XXAA_NETWORK)
  zephyr_compile_definitions_ifdef(CONFIG_SOC_NRF9160        NRF9160_XXAA)

  # Connect Kconfig compilation option for Non-Secure software with option required by MDK/nrfx
  zephyr_compile_definitions_ifdef(CONFIG_ARM_NONSECURE_FIRMWARE NRF_TRUSTZONE_NONSECURE)

  zephyr_library_sources_ifdef(CONFIG_SOC_SERIES_NRF51X  nrfx/mdk/system_nrf51.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF52810       nrfx/mdk/system_nrf52810.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF52811       nrfx/mdk/system_nrf52811.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF52832       nrfx/mdk/system_nrf52.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF52833       nrfx/mdk/system_nrf52833.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF52840       nrfx/mdk/system_nrf52840.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF5340_CPUAPP nrfx/mdk/system_nrf5340_application.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF5340_CPUNET nrfx/mdk/system_nrf5340_network.c)
  zephyr_library_sources_ifdef(CONFIG_SOC_NRF9160        nrfx/mdk/system_nrf9160.c)

  zephyr_library_sources(nrfx_glue.c)

  zephyr_library_sources_ifdef(CONFIG_NRFX_PRS     nrfx/drivers/prs/nrfx_prs.c)

  zephyr_library_sources_ifdef(CONFIG_NRFX_ADC     nrfx/drivers/src/nrfx_adc.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_CLOCK   nrfx/drivers/src/nrfx_clock.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_COMP    nrfx/drivers/src/nrfx_comp.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_DPPI    nrfx/drivers/src/nrfx_dppi.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_EGU     nrfx/drivers/src/nrfx_egu.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_GPIOTE  nrfx/drivers/src/nrfx_gpiote.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_I2S     nrfx/drivers/src/nrfx_i2s.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_IPC     nrfx/drivers/src/nrfx_ipc.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_LPCOMP  nrfx/drivers/src/nrfx_lpcomp.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_NFCT    nrfx/drivers/src/nrfx_nfct.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_NVMC    nrfx/drivers/src/nrfx_nvmc.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_PDM     nrfx/drivers/src/nrfx_pdm.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_POWER   nrfx/drivers/src/nrfx_power.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_PPI     nrfx/drivers/src/nrfx_ppi.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_PWM     nrfx/drivers/src/nrfx_pwm.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_QDEC    nrfx/drivers/src/nrfx_qdec.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_QSPI    nrfx/drivers/src/nrfx_qspi.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_RNG     nrfx/drivers/src/nrfx_rng.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_RTC     nrfx/drivers/src/nrfx_rtc.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_SAADC   nrfx/drivers/src/nrfx_saadc.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_SPI     nrfx/drivers/src/nrfx_spi.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_SPIM    nrfx/drivers/src/nrfx_spim.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_SPIS    nrfx/drivers/src/nrfx_spis.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_SYSTICK nrfx/drivers/src/nrfx_systick.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_TEMP    nrfx/drivers/src/nrfx_temp.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_TIMER   nrfx/drivers/src/nrfx_timer.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_TWI     nrfx/drivers/src/nrfx_twi.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_TWIM    nrfx/drivers/src/nrfx_twim.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_TWIS    nrfx/drivers/src/nrfx_twis.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_UART    nrfx/drivers/src/nrfx_uart.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_UARTE   nrfx/drivers/src/nrfx_uarte.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_USBD    nrfx/drivers/src/nrfx_usbd.c)
  zephyr_library_sources_ifdef(CONFIG_NRFX_WDT     nrfx/drivers/src/nrfx_wdt.c)

  if(CONFIG_NRFX_TWI OR CONFIG_NRFX_TWIM)
    zephyr_library_sources(nrfx/drivers/src/nrfx_twi_twim.c)
  endif()
endif()
